#include <iostream>
#include <vector>
#include <sstream>

int main()
{
    int N;
    std::cin >> N;
    std::cin.ignore();

    std::string ss;
    std::getline(std::cin, ss);
    std::istringstream iss(ss);

    int k;
    std::cin >> k;

    int n;
    std::vector<int> score_vec;
    while (iss >> n)
    {
        score_vec.push_back(n);
    }

    std::vector<int> max_scores(N, 0);
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j <= k; j++)
        {
            if (i >= j)
                max_scores[i] = std::max(max_scores[i], max_scores[i - j] + score_vec[i]);
        }
    }

    std::cout << max_scores[N - 1] << std::endl;

    return 0;
}